import request from '@/utils/request'

/**
 * 广告
 * @type {{addAdvert: (function(*=): *), deleteAdvert: (function(*): *), listAdvert: (function(*): *), editAdvert: (function(*=): *)}}
 */
export const AdvertService = {
  // 广告列表
  listAdvert: function(query) { return request({ method: 'get', url: '/manage/advert/list.do', params: { ...query }}) },
  // 新增广告
  addAdvert: function(data) { return request({ method: 'post', url: '/manage/advert/add.do', data: data }) },
  // 编辑广告
  editAdvert: function(data) { return request({ method: 'post', url: '/manage/advert/edit.do', data: data }) },
  // 删除广告
  deleteAdvert: function(id) { return request({ method: 'post', url: '/manage/advert/delete.do', data: [id] }) },
  // 广告类型列表
  listAdvertType: function(query) { return request({ method: 'get', url: '/manage/advert/type/list.do', params: { ...query }}) },
  // 所有广告类型
  getAllAdvertType: function() { return request({ method: 'get', url: '/manage/advert/type/all.do' }) },
  // 新增广告类型
  addAdvertType: function(data) { return request({ method: 'post', url: '/manage/advert/type/add.do', data: data }) },
  // 编辑广告类型
  editAdvertType: function(data) { return request({ method: 'post', url: '/manage/advert/type/edit.do', data: data }) },
  // 删除广告类型
  deleteAdvertType: function(id) { return request({ method: 'post', url: '/manage/advert/type/delete.do', data: [id] }) }
}

/**
 * 优惠卷
 * @type {{deleteCoupon: (function(*): *), listCoupon: (function(*): *), activeCoupon: (function(*=, *=): *), addCoupon: (function(*=): *)}}
 */
export const CouponService = {
  // 优惠卷列表
  listCoupon: function(query) { return request({ method: 'get', url: '/manage/coupon/list.do', params: { ...query }}) },
  // 修改优惠卷活动状态
  activeCoupon: function(couponId, status) { return request({ method: 'get', url: '/manage/coupon/editStatus.do', params: { couponId: couponId, status: status }}) },
  // 删除优惠卷
  deleteCoupon: function(data) { return request({ method: 'post', url: '/manage/coupon/delete.do', data: [data] }) },
  // 新增优惠卷
  addCoupon: function(data) { return request({ method: 'post', url: '/manage/coupon/add.do', data: data }) },
  // 优惠卷领券记录
  getUserGetRecord: function(query) { return request({ method: 'get', url: '/manage/coupon/getrecord.do', params: { ...query }}) }
}
